/**                           _ooOoo_
 *                           o8888888o
 *                           88" . "88
 *                           (| -_- |)
 *                            O\ = /O
 *                        ____/`---'\____
 *                      .   ' \\| |// `.
 *                       / \\||| : |||// \
 *                     / _||||| -:- |||||- \
 *                       | | \\\ - /// | |
 *                     | \_| ''\---/'' | |
 *                      \ .-\__ `-` ___/-. /
 *                   ___`. .' /--.--\ `. . __
 *                ."" '< `.___\_<|>_/___.' >'"".
 *               | | : `- \`.;`\ _ /`;.`/ - ` : | |
 *                \ \ `-. \_ __\ /__ _/ .-` / /
 *         ======`-.____`-.___\_____/___.-`____.-'======
 *                            `=---='
 *
 *         .............................................
 *                 佛祖保佑             永无BUG
 *
 *       Created by k on 2015/5/12. email:527565073@qq.com
 */
;(function($){
    var pluginName = "pupLayer",
        _default = {
            width:900
        }

    var pup = function(elem,options){
        this.elem = elem; //Dom对象
        this.$elem = $(this.elem); //jquery对象
        this.options = $.extend({},_default,options || "");
        this.init();
    }

    pup.prototype={
        init:function(){
            this.$elem.find('.u-sel-input').bind('click',{myOptions:this.options},function(e){
                var $options = e.data.myOptions;
                var $this = $(this);
                var str = "";
                var arrayName = "";
                var id = $this.attr('id');
                if(id=="positions"){
                    arrayName=posiArray;
                }else if(id=="trades"){
                    arrayName=tradeArray;
                }else if(id=="publishTimes"){
                    var dateArray=new Array();
                    dateArray[0]=new Array("近一天","1");
                    dateArray[1]=new Array("近两天","2");
                    dateArray[2]=new Array("近三天","3");
                    dateArray[3]=new Array("近一周","7");
                    dateArray[4]=new Array("近两周","15");
                    dateArray[5]=new Array("近一月","30");
                    dateArray[6]=new Array("近六周","45");
                    dateArray[7]=new Array("近两月","60");
                    arrayName=dateArray;
                }else if(id=="areas"){
                    //arrayName=areaArray;
                }else if(id=="salarys"){
                    var payArray=new Array();
                    payArray[0]=new Array("面议","1","0");
                    payArray[1]=new Array("1500元以下","2","1499");
                    payArray[2]=new Array("1500～1999元","3","1501");
                    payArray[3]=new Array("2000～2999元","4","2001");
                    payArray[4]=new Array("3000～4499元","5","3001");
                    payArray[5]=new Array("4500～5999元","6","4501");
                    payArray[6]=new Array("6000～7999元","7","6001");
                    payArray[7]=new Array("8000～9999元","8","8001");
                    payArray[8]=new Array("10000～14999元","9","10001");
                    payArray[9]=new Array("15000～19999元","10","15001");
                    payArray[10]=new Array("20000～29999元","11","20001");
                    payArray[11]=new Array("30000～49999元","12","30001");
                    payArray[12]=new Array("50000元以上","13","50001");
                    arrayName=payArray;
                }else if(id=="graduates"){
                    var eduArray=new Array();
                    eduArray[0]=new Array("初中","1","Junior High School");
                    eduArray[1]=new Array("高中","2","Senior High School");
                    eduArray[2]=new Array("职高/技校","3","Vocational high school/Technical School");
                    eduArray[3]=new Array("中专","4","Technical Secondary School");
                    eduArray[4]=new Array("大专","5","Junior College");
                    eduArray[5]=new Array("大学本科","6","Bachelor");
                    eduArray[6]=new Array("硕士","7","Master");
                    eduArray[7]=new Array("博士","8","Doctorate");
                    arrayName=eduArray;
                }else if(id=="experiences"){
                    var workArray = new Array();
                    workArray[0]=new Array("1年以内","1");
                    workArray[1]=new Array("1~2年","2");
                    workArray[2]=new Array("3~5年","3");
                    workArray[3]=new Array("5年以上","4");
                    arrayName=workArray;
                }
                //str+="<div class='shadow' id='shadow'></div>";
                str+="<div class='layout' id='layout'>";
                str+="<ul class='layout_ul'>";
                for(j=0;j<arrayName.length;j++){
                    str+="<li id='"+arrayName[j][2]+"' title='"+arrayName[j][0]+"'>"+arrayName[j][0]+"</li>";
                }
                str+="</ul>";
                str+="</div>";
                if($('#layout')[0]){
                    $('#layout').remove();
                    $this .parent().append(str);
                }else{
                    $this.parent().append(str);
                }
                $this.addClass('z-crt').parent('li').siblings().find('.u-sel-input').removeClass('z-crt');

                $('.layout_ul li').bind('click',function(){
                    var val = $(this).text();
                    var id = $(this).attr('id');
                    $this.val(val);
                    $this.prev().val(id);
                    $this.removeClass('z-crt');
                    $('#layout').remove();
                })
            })
        }
    }

    $.fn[pluginName]=function(options){
        return this.each(function(){
            new pup(this,options)
        })
    }






})(jQuery);




